<?session_start();

$usuario = $_POST['usuario'];
$password = $_POST['pass'];
include ("conectarse.php");
$password = crypt($password,"abc");
$consulta = "select * from usuarios where us_relacion like '$usuario'";
$resultado = mysql_query($consulta);
$fila = mysql_fetch_array($resultado);
$cantidad = mysql_num_rows($resultado);
$id = $fila['us_id'];
$tipo = $fila['us_tipo'];
$pass1 = $fila['us_pass1'];
$pass2 = $fila['us_pass2'];

if($cantidad=="0"){header("Location:index.php?error=1");}else{





if(($pass1)==''){header("Location:crea_pass1.php?id=$id");}else{

if(($pass1!=$password)&&($pass2!=$password)){header("Location:index.php?error=2");}

if(($pass1==$password)||($pass2==$password)){

$_SESSION['usuario'] = $usuario;

$_SESSION['tipo'] = $tipo;

if($tipo=="1"){header("Location:./cliente/index.php");}
elseif($tipo=="2"){header("Location:./mutual/index.php");}
elseif($tipo=="3"){header("Location:./mutuar/index.php");}
elseif($tipo=="4"){header("Location:./consola/index.php");}

}}



				}									

?>